#include "Input.h"
#include "DxLib.h"

// -------------------------- //

Input::Input(void)
	: Singleton( this )
{
	memset( m_previousKeys, 0, sizeof( m_previousKeys ) );
	memset( m_currentKeys, 0, sizeof( m_currentKeys ) );
}

// -------------------------- //

Input::~Input(void)
{
}

// -------------------------- //

void Input::Update( float delta )
{
	memcpy( m_previousKeys, m_currentKeys, sizeof( m_currentKeys ) );
	GetHitKeyStateAll( m_currentKeys );
}

// -------------------------- //

bool Input::IsKeyDown( unsigned int key )
{
	return ( m_currentKeys[ key ] == 1 );
}

// -------------------------- //

bool Input::IsKeyPressed( unsigned int key )
{
	return ( m_currentKeys[ key ] == 1 
			&& m_previousKeys[ key ] == 0
		  );
}

// -------------------------- //

bool Input::IsKeyReleased( unsigned int key )
{
	return ( m_currentKeys[ key ] == 0 
			&& m_previousKeys[ key ] == 1
		  );
}

// -------------------------- //

bool Input::IsKeyUp( unsigned int key )
{
	return ( m_currentKeys[ key ] == 0 );
}

